const mysql = require('mysql2')

const connection = mysql.createConnection({
    'host': '127.0.0.1',
    'user': 'mydb',
    'password': 'mydb',
    'database': 'testmydb'
})
connection.connect()

//查询的SQL语句
var selSql = 'SELECT *  FROM bookinfo';
//查询操作
connection.query
    (selSql, function (err, results, fields) {
        if (err) throw err;
        console.log('-------查询记录----------');
        console.log('查询结果:', results);
        // console.log('查询结果字段:', fields);

    });
connection.end();
